//
//  TimeAddViewController.m
//  味·道
//
//  Created by lizi on 15/7/2.
//  Copyright (c) 2015年 WMR. All rights reserved.
//

#import "TimeAddViewController.h"
#import "TimeDreminderViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "MaocHeader.h"

@interface TimeAddViewController ()
@property (retain,nonatomic)UIDatePicker *dataPicker;
@property (nonatomic,retain)UILabel *label;
@property (nonatomic,retain)UIView *view2;
@property (nonatomic,retain)NSDate *selected;
@end

@implementation TimeAddViewController
- (void)dealloc
{
    [_dataPicker release];
    [_label release];
    [_textView release];
    [_view2 release];
    [_selected release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.5 alpha:1];
    self.dataArr = [[NSMutableArray alloc] initWithCapacity:10];
    [self WL_setUpViews];
    [self createBackBtn];
    [self createCustomLab];
    [self createStoreBtn];
    // Do any additional setup after loading the view.
}

- (void)createCustomLab{
    UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(150, 20, 100, 30)];
    [customLab setTextColor:[UIColor whiteColor]];
    [customLab setText:@"添加定时提醒"];
    customLab.font = [UIFont boldSystemFontOfSize:20];
    [self.view addSubview:customLab];
    [customLab release];
}
- (void)createStoreBtn{
    UIButton *storeBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];
    storeBtn.frame = CGRectMake(SCREEN_WIDTH-60, 20, 40, 30);
    [storeBtn addTarget:self action:@selector(storeChange:) forControlEvents:UIControlEventTouchUpInside];
    [storeBtn setTitle:@"完成" forState:(UIControlStateNormal)];
    [self.view addSubview:storeBtn];
}
- (void)storeChange:(UIButton *)button{
    TimeDreminderViewController *timeVC = [[TimeDreminderViewController alloc] init];
//    timeVC.isEdite = YES;
    timeVC.str = self.textView.text;
    timeVC.num++;
    NSLog(@"num:%d",timeVC.num);
    [timeVC.rightVC.view addSubview:timeVC.view];
//    _selected = [NSDate date];
//    _selected = [self.dataPicker date];
//    [self.navigationController popToViewController:timeVC animated:YES];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)createBackBtn{
    UIButton *back = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [back setTitle:@"返回" forState:UIControlStateNormal];
    [back addTarget:self action:@selector(backFor:) forControlEvents:UIControlEventTouchUpInside];
    back.frame = CGRectMake(10, 10, 50, 50);
    [self.view addSubview:back];
}
- (void)backFor:(UIButton *)button{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)WL_setUpViews{
    _view2 = [[UIView alloc] initWithFrame:CGRectMake(1, 55, SCREEN_WIDTH, SCREEN_HEIGHT-55)];
    _view2.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_view2];
    [_view2 release];
    
    _label = [[UILabel alloc] initWithFrame:CGRectMake(30, 15, SCREEN_WIDTH-60, 30)];
    _label.textColor = [UIColor grayColor];
    _label.text = @"关于描述的提醒：（如：小火30分钟）";
    [self.view2 addSubview:_label];
    [_label release];

//    _textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, SCREEN_WIDTH-26, 124)];
//    _textField.delegate = self;
//    _textField.layer.cornerRadius = 5.0f;
//    _textField.text = @"添加定时啦。。。";
//    [self.view2 addSubview:_textField];
//    [_textField release];
    
    
    _textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 50, SCREEN_WIDTH-40, 124)];
    _textView.font = [UIFont systemFontOfSize:20];
    _textView.text = @"添加定时啦。。。";
    _textView.layer.borderWidth = 1.0;
    _textView.layer.cornerRadius = 5.0f;
    [self.view2 addSubview:_textView];

//    CAShapeLayer *shadowLayer = [CAShapeLayer layer];
//    [shadowLayer setFrame:_textField.bounds];
//    [shadowLayer setShadowColor:[UIColor colorWithWhite:0 alpha:1].CGColor];
//    [shadowLayer setShadowOffset:CGSizeMake(0.0f, 0.0f)];
//    [shadowLayer setShadowOpacity:1.0f];
//    [shadowLayer setShadowRadius:4];
//    [shadowLayer setFillRule:kCAFillRuleEvenOdd];
//    CGMutablePathRef path = CGPathCreateMutable();
//    CGPathAddRect(path, NULL, CGRectInset(_textField.bounds, -42, -42));
//    CGPathRef someInnerPath = [UIBezierPath bezierPathWithRoundedRect:_textField.bounds cornerRadius:10.0f].CGPath;
//    CGPathAddPath(path, NULL, someInnerPath);
//    CGPathCloseSubpath(path);
//    [shadowLayer setPath:path];
//    CGPathRelease(path);
//    [[_textField layer] addSublayer:shadowLayer];
//    CAShapeLayer* maskLayer = [CAShapeLayer layer];
//    [maskLayer setPath:someInnerPath];
//    [shadowLayer setMask:maskLayer];
    
    _dataPicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(10, 220, SCREEN_WIDTH-20, 100)];
    [self.view2 addSubview:_dataPicker];
    [_dataPicker release];
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [_textView resignFirstResponder];
    return YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
